package com.itheima.d2_this;

/**
 * this访问构造器
 *              this(...)使用时还可以访问类中的构造器，无参和有参的均可以
 */
public class Student {
    private String name;
    private String SchoolName;

    public  Student(){

    }

    public Student(String name){
        /**
         * 用户在只输入了name时，会触发该构造器
         * 本构造器使用this关键字访问有参构造器public Student(String name, String schoolName)
         * 会将SchoolName字段自动设置为"cqupt"
         */

        this(name,"cqupt");
    }

    public Student(String name, String schoolName) {
        this.name = name;
        SchoolName = schoolName;

    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSchoolName() {
        return SchoolName;
    }

    public void setSchoolName(String schoolName) {
        SchoolName = schoolName;
    }
}
